package com.gec.service.impl;

import com.gec.common.RecognitionException;
import com.gec.common.RecognitionItem;
import com.gec.common.RecognitionResult;
import com.gec.entity.Goods;
import com.gec.entity.Layer;
import com.gec.entity.Stock;
import com.gec.service.RecognitionService;
import com.gec.util.RecognitionTool;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ahthor: lxj
 * @date: 2024/4/9 14:57
 * @title:
 **/
@Service
public class RecognitionServiceImpl implements RecognitionService {
    @Override
    public RecognitionResult recognition(List<Layer> openLayers, List<Layer> closeLayers, List<Goods> goodsList, List<Stock> stockList) {
        // 测试识别算法
        RecognitionTool recognitionTool = new RecognitionTool(1,2);

        RecognitionResult result = recognitionTool.recognize(openLayers, closeLayers, goodsList, stockList);


        // 输出识别结果
        System.out.println("Recognition Successful: " + result.isSuccessful());
        System.out.println("Shopping List: ");
        for (RecognitionItem item : result.getItems()) {
            System.out.println(item.getGoodsId() + " - Quantity: " + item.getNum());
        }
        System.out.println("Exceptions: ");
        for (RecognitionException exception : result.getExceptions()) {
            System.out.println("Layer: " + exception.getLayer() + " - Exception: " + exception.getException());
        }
        return result;
    }
}
